package com.liquidhorse.core;

import java.text.DecimalFormat;

public final class TLEvent {
	private int id = -1;
	private String title = null;
	private String description = null;
	private boolean running = false;
	private boolean finished = false;
	
	private int remainingMinutes = 0;

	private int h_KST = 0;
	private int m_KST = 0;
	private int h_CEST = 0;
	private int m_CEST = 0;
	private int h_EDT = 0;
	private int m_EDT = 0;
	private int h_PDT = 0;
	private int m_PDT = 0;
	
	private DecimalFormat df = new DecimalFormat("00");
	
	public String getStatus() {
		String status = "";
		
		if (this.finished) {
			status = "<font color=RED>Finished</font>";
		} else if (this.running) {
			status = "<font color=GREEN>Running!</font>";
		} else {
			int days = this.remainingMinutes / (60 * 24);
			int hours = (this.remainingMinutes - days * 24 * 60) / 60;
			int minutes = this.remainingMinutes - days * 24 * 60 - hours * 60;
			
			if (days > 0) {
				status += days + " days ";
			}
			if (hours > 0) {
				status += hours + " hours ";
			}
			if (minutes > 0) {
				status += minutes + " minutes ";
			}
		}
		
		return status;
	}
	
	public int getRemainingMinutes() {
		return remainingMinutes;
	}
	
	public String getKST() {
		return this.df.format(this.h_KST) + ":" + this.df.format(this.m_KST) + " KST";
	}
	
	public String getCEST() {
		return this.df.format(this.h_CEST) + ":" + this.df.format(this.m_CEST) + " CEST";
	}
	
	public String getEDT() {
		return this.df.format(this.h_EDT) + ":" + this.df.format(this.m_EDT) + " EDT";
	}
	
	public String getPDT() {
		return this.df.format(this.h_PDT) + ":" + this.df.format(this.m_PDT) + " PDT";
	}
	
	public void addDays(int days) {
		this.remainingMinutes += days * 24 * 60;
	}
	public void addHours(int hours) {
		this.remainingMinutes += hours * 60;
	}
	public void addMinutes(int minutes) {
		this.remainingMinutes += minutes;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public boolean isRunning() {
		return running;
	}
	public void setRunning(boolean running) {
		this.running = running;
	}
	public boolean isFinished() {
		return finished;
	}
	public void setFinished(boolean finished) {
		this.finished = finished;
	}
	
	public int getH_KST() {
		return h_KST;
	}
	public void setH_KST(int h_KST) {
		this.h_KST = h_KST;
	}
	public int getM_KST() {
		return m_KST;
	}
	public void setM_KST(int m_KST) {
		this.m_KST = m_KST;
	}
	public int getH_CEST() {
		return h_CEST;
	}
	public void setH_CEST(int h_CEST) {
		this.h_CEST = h_CEST;
	}
	public int getM_CEST() {
		return m_CEST;
	}
	public void setM_CEST(int m_CEST) {
		this.m_CEST = m_CEST;
	}
	public int getH_EDT() {
		return h_EDT;
	}
	public void setH_EDT(int h_EDT) {
		this.h_EDT = h_EDT;
	}
	public int getM_EDT() {
		return m_EDT;
	}
	public void setM_EDT(int m_EDT) {
		this.m_EDT = m_EDT;
	}
	public int getH_PDT() {
		return h_PDT;
	}
	public void setH_PDT(int h_PDT) {
		this.h_PDT = h_PDT;
	}
	public int getM_PDT() {
		return m_PDT;
	}
	public void setM_PDT(int m_PDT) {
		this.m_PDT = m_PDT;
	}
	
	@Override
	public String toString() {
		return "ID=" + this.id + " TITLE=" + this.title + " DESCRIPTION=" + this.description 
		+ " " + " RUNNING=" + this.running + " FINISHED=" + this.finished 
		+ " COUNTDOWN=" + this.remainingMinutes 
		+ " KST=" + this.h_KST + ":" + this.m_KST
		+ " CEST=" + this.h_CEST + ":" + this.m_CEST
		+ " EDT=" + this.h_EDT + ":" + this.m_EDT
		+ " PDT=" + this.h_PDT + ":" + this.m_PDT;
	}
}
